iT邦幫忙

2025 iThome 鐵人賽

DAY 8
0
AI & Data

30 天打造 App 評論洞察系統:用 AI 讓產品團隊更懂用戶系列 第 8

【Day 7】App 評論爬蟲設計與實作(4/5)

  • 分享至 

  • xImage
  •  

在資料收集的過程中,我們會發現 App Store 與 Google Play 的爬蟲結果雖然都是評論資料,但它們的結構往往不同。例如:

  • App Store:通常欄位包含 title, content, rating, updated
  • Google Play:欄位則是 userName, content, score, at

這樣的情況下,若要後續進行分析,就會遇到欄位名稱與結構對不上,難以直接合併。
因此,今天的任務是:將不同來源的資料,轉換成統一的格式


統一的欄位格式

我們設定以下五個欄位作為標準格式:

  • title → 評論標題(若無標題,則填入空字串 ""
  • review → 評論內容
  • rating → 評分(數字 1–5)
  • date → 評論日期
  • platform → 資料來源("App Store""Google Play"

範例程式碼

import pandas as pd


# 轉換 App Store 格式
df_app_store = pd.DataFrame(app_store_data)
df_app_store = df_app_store.rename(columns={
    "content": "review",
    "updated": "date"
})
df_app_store["platform"] = "App Store"

# 轉換 Google Play 格式
df_google_play = pd.DataFrame(google_play_data)
df_google_play = df_google_play.rename(columns={
    "content": "review",
    "score": "rating",
    "at": "date"
})
df_google_play["title"] = ""   # Google Play 無標題
df_google_play["platform"] = "Google Play"
df_google_play = df_google_play[["title", "review", "rating", "date", "platform"]]

# App Store 保留相同欄位順序
df_app_store = df_app_store[["title", "review", "rating", "date", "platform"]]

df_google_play
# df_app_store

到這裡,我們已經把兩種資料整理成一致的欄位格式,為資料合併做好準備。

下方圖片為整理好的資料表內容
https://ithelp.ithome.com.tw/upload/images/20250828/20169646Yj1lLbYRoQ.png


上一篇
【Day 6】App 評論爬蟲設計與實作(3/5)
下一篇
【Day 8】App 評論爬蟲設計與實作(5/5)
系列文
30 天打造 App 評論洞察系統:用 AI 讓產品團隊更懂用戶14
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言